package com.shihb.behavioralpatterns.mementopattern;

/**
 *Description:备忘录模式
 *Version:1.0.0
 *@author shihb
 *@date 2020/4/21 11:24
 */
public class Client {

  public static void main(String[] args) {
    Caretaker caretaker = new Caretaker();
    GameRole shb = new GameRole("shb");
    shb.setAp(100);
    shb.setDefense(100);
    System.out.println("===========打boss前存状态");
    caretaker.addMemento(shb.getName(),shb.saveState());
    shb.showState();
    System.out.println("===========打boss中消耗状态");
    shb.setAp(50);
    shb.setDefense(50);
    shb.showState();
    System.out.println("===========打boss后恢复状态");
    shb.recover(caretaker.getMemento(shb.getName()));
    shb.showState();


  }
}
